// 调接口
import http from "@/utils/http";
// 封装api接口
export const xx = (data) => {
  return http({
    url: "",
    method: "POST",
    data,
  });
};
// 添加请求拦截器
instance.interceptors.request.use(
  function (config) {
    let token = localStorage.getItem("token");
    if (token) {
      config.headers.token = token;
    }
    return config;
  },
  function (error) {
    return Promise.reject(error);
  }
);
// 添加响应拦截器
instance.interceptors.response.use(
  function (response) {
    if (response.data.code == 10119) {
      localStorage.removeItem("token");
      router.replace("/login");
    }
    return response.data;
    // return response;
  },
  function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
  }
);
